home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 101-125 / 105 / pere-et-fils / startproc.asm < prev    next >
Assembly Source File  |  1995-03-13  |  2KB  |  76 lines

  1.  
  2. ************************************************************************
  3. *
  4. *       C reentrant process Startup/Exit           (JM Forgeas 13-06-87)
  5. *       compile (under Lattice) multiple process on once loaded code 
  6. *
  7. ************************************************************************
  8.  
  9.  
  10. ******* Included Files *************************************************
  11.  
  12.         INCLUDE "exec/types.i"
  13.         INCLUDE "exec/libraries.i"
  14.         INCLUDE "exec/tasks.i"
  15.  
  16.  
  17. ******* Imported *******************************************************
  18.  
  19. xlib    macro
  20.         xref    _LVO\1
  21.         endm
  22.  
  23.         xref    _AbsExecBase        ; the only one absolute system adress
  24.         xref    _main               ; C code entry point
  25.  
  26.         xlib    Forbid
  27.         xlib    Permit
  28.  
  29.  
  30. ******* Exported *******************************************************
  31.  
  32.         xdef   _SysBase            ; Lattice seems to need it
  33.         xdef   _exit               ; standard C exit function
  34.  
  35. callsys MACRO
  36.         CALLLIB _LVO\1
  37.         ENDM
  38.  
  39.  
  40. ************************************************************************
  41. *
  42. *       Standard Program Entry Point
  43. *
  44. ************************************************************************
  45.  
  46. startup:
  47.                move.l _AbsExecBase,a6    ; get Exec's library base ptr
  48.                callsys  Forbid           ; writing together...
  49.                move.l a6,_SysBase        ; save it in _SysBase
  50.                callsys  Permit           ; other process can read it
  51.  
  52.                move.l SP,d0              ; send initial task stack ptr
  53.                move.l d0,-(SP)           ;      to:  main(initialSP)
  54.  
  55.                jsr    _main              ; main() opens doslib itself
  56.  
  57.  
  58.         ;------ return or exit from code:
  59. _exit:
  60.                move.l         4(SP),d0   ; restore stack ptr stored and
  61.                move.l         d0,SP      ;      returned by _main
  62.                moveq.l        #0,d0
  63.                rts
  64.  
  65.  
  66. ************************************************************************
  67.  
  68.         DATA
  69.  
  70. ************************************************************************
  71.  
  72. _SysBase       dc.l   0
  73.  
  74.  
  75.         END
  76.